package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class BibliotecaApp extends Biblioteca{

    public static void main(String[] args) throws IOException {
        Biblioteca biblioteca = new Biblioteca();
        biblioteca.add(new Book("First Book"));
        biblioteca.add(new Book("Second Book"));
        biblioteca.add(new Movie("First Movie", "2012", "Direc Tor", 9));

        appSays(biblioteca.loginMessage());
        String s = getInputLine();
        if(biblioteca.login(s)){
            appSays(biblioteca.welcomeMessage());
            s = getInputLine();
            while (!"exit".equals(s)){
                appSays(biblioteca.getCommand(s));
                s = getInputLine();
            }
        }else {
            appSays(BiblioMessages.LOGIN_FAIL);
        }
    }

    private static String getInputLine() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        return br.readLine();
    }

    public static void appSays(String say) {
        System.out.println(say);
        System.out.println();
    }

}
